#include <stdio.h>
#include <stdlib.h>

using namespace std;

int data[0x80 * 0x20];

void printdata();
void searchfor_PDE();
void searchfor_PTE();
void searchfor_ADDR();
void printAnswer();

int request, index;
int list_base = 0x220;

int main(){
    scanf("%x", &request);
    freopen("data.txt", "r", stdin);
    freopen("answer.out", "w", stdout);
    for(int i = 0; i < 0x80; ++ i){
        char x[11], y[11];
        scanf("%s %s:", x, y);
        for(int j = 0; j < 0x20; ++ j){
            scanf("%x", &data[i*0x20+j]);
        }
    }
    printf("Virtual Address %04x:\n", request);
    searchfor_PDE();
    searchfor_PTE();
    searchfor_ADDR();
    printAnswer();
    return 0;
}

void printdata(){
    for(int i = 0; i < 0x80; ++ i){
        for(int j = 0; j < 0x20; ++ j){
            printf("%02x ", data[i*0x80+j]);
        }
        printf("\n");
    }
}

void searchfor_PDE(){
    index = list_base + (request>>10);
    return;
}

void searchfor_PTE(){
    int flag = data[index] >> 7;
    int pointer = data[index]&((1<<7)-1);
    printf("--> pde index:0x%02x  pde contents:(valid %d, pfn 0x%02x)\n", (request>>10), flag, pointer);
    if(flag == 1){
        index = (pointer<<5) | (request>>5)&((1<<5)-1);
    }else{
        printf("    --> Fault (page directory entry not valid)\n");
		exit(0);
    }
    return;
}

void searchfor_ADDR(){
    int flag = data[index] >> 7;
    int pointer = data[index]&((1<<7)-1);
    printf("    --> pte index:0x%02x  pte contents:(valid %d, pfn 0x%02x)\n", (request>>5)&((1<<5)-1), flag, pointer);
    if(flag == 1){
        index = (pointer<<5) | (request)&((1<<5)-1);
    }else{
        printf("      --> Fault (page table entry not valid)\n");
        exit(0);
    }
    return;
}

void printAnswer(){
    printf("      --> Translates to Physical Address 0x%x --> Value: 0x%x\n", index, data[index]);
    return;
}